package com.itheima.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo03 {
    public static void main(String[] args) {
        Collection<String> list= new ArrayList<>();

        list.add("鹿晗");
        list.add("关晓彤");
        list.add("鹿晗");
        list.add("鹿晗");
        list.add("蔡徐坤");
       //list.remove("鹿晗");
       // list.removeIf(s -> s.equals("鹿晗"));//list.removeIf 自带一个遍历
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            if(next.equals("鹿晗")){
                iterator.remove();
                //list.remove(next)
            }
        }
        System.out.println(list);

    }
}
